// import { createRouter, createWebHistory, useRouter, type Router, type RouteRecordRaw } from 'vue-router'

// import MainLayout from '@/layouts/MainLayout.vue'

// export const routes: RouteRecordRaw[] = [
//   {
//     path: '/login',
//     component: () => import('@/views/login/LoginPage.vue'),
//     meta: { hidden: true },
//   },
//   {
//     path: '/',
//     redirect: '/workbench',
//     meta: { hidden: true },
//   },
//   {
//     path: '/workbench',
//     component: MainLayout,
//     children: [
//       {
//         path: '',
//         component: () => import('@/views/workbench/WorkbenchPage.vue'),
//         meta: { title: '工作台', icon: 'workbench' },
//       },
//     ],
//   },
//   // 新增月卡管理页
//   {
//     path: '/cardAdd',
//     component: () => import('@/views/car/AddCard.vue'),
//     meta: { hidden: true },
//   },
//   {
//     path: '/exterpriseAdd',
//     component: () => import('@/views/park/AddEnterprise.vue')
//   },
//   {
//     path: '/exterpriseDetail',
//     component: () => import('@/views/park/EnterpriseDetail.vue')
//   },
//   {
//     path: '/roleAdd',
//     component: () => import('@/views/system/AddRole.vue')
//   },
//   {
//     path: '/:pathMatch(.*)*',
//     component: () => import('@/views/NotFound.vue'),
//     meta: { hidden: true },
//   },
// ]

// const router = createRouter({
//   history: createWebHistory(import.meta.env.BASE_URL),
//   scrollBehavior: () => ({ top: 0 }),
//   routes,
// })


// export default router
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'

import MainLayout from '@/layouts/MainLayout.vue'

export const routes: RouteRecordRaw[] = [
  {
    path: '/roleAdd/:id?',
    component: () => import('@/views/system/AddRole.vue'),
    meta: { hidden: true }
  },
  {
    path: '/exterpriseDetail/:id?',
    component: () => import('@/views/park/EnterpriseDetail.vue'),
    meta: { hidden: true }
  },
  {
    path: '/exterpriseAdd',
    component: () => import('@/views/park/AddEnterprise.vue'),
    meta: { hidden: true }
  },
  {
    path:'/cardAdd/:id?',
    component: () => import('@/views/car/AddCard.vue'),
    meta: { hidden: true }
  },
  {
    path: '/login',
    component: () => import('@/views/login/LoginPage.vue'),
    meta: { hidden: true },
  },
  {
    path: '/',
    redirect: '/workbench',
    meta: { hidden: true },
  },
  {
    path: '/workbench',
    component: MainLayout,
    children: [
      {
        path: '',
        component: () => import('@/views/workbench/WorkbenchPage.vue'),
        meta: { title: '工作台', icon: 'workbench' },
      },
    ],
  },
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/views/NotFound.vue'),
    meta: { hidden: true },
  },
]

const router = createRouter({
  // mode: 'history
  // import.meta.env.BASE_URL  环境变量 默认值是 /
  history: createWebHistory(import.meta.env.BASE_URL),
  // 切换页面是，滚动到顶部
  scrollBehavior: () => ({ top: 0 }),
  // 路由表
  routes,
})

export default router